package com.java.test.JVM.classLoader;


import java.util.Random;

/**
 * @project MyBlog
 * @create 2013年6月18日 下午7:00:45
 * @version 1.0.0
 * @author 张广
 */
public class Toy {
    private String name;

    public void setName(String name) {
        this.name = name;
    }

    public static final int price=10;

    // 下面几种都不是编译时常量
    static int a;

    final  int b;

    static final  int c= new Random().nextInt(100);

    static final  int d;
    static {
        System.out.println("Initializing d=5");
        d=5;
    }
    // 上面几种都不是编译时常量

    static {
        System.out.println("Initializing block");
    }

    Toy() {
        System.out.println("Building");
        b=1;
    }
    Toy(String name) {
        this.setName(name);
        System.out.println("Building with "+name);
        b=2;
    }

    public static String playToy(String player) {
        String msg = "";//buildMsg(player);
        System.out.println(msg);
        return msg;
    }
    private String buildMsg(String player) {
        String msg = player + " plays " + name;
        return msg;
    }
}

